
export function checkStatus(res){
  let status = res.status || -1000
  if((status >= 200 && status < 300) || status === 304){
    return res.data
  } else {
    let errInfo = ''
    switch (status) {
      case -1000:
        errInfo = '远程服务响应失败,请稍后重试'
        break
      case 400:
        errInfo = '400:错误请求'
        break
      case 401:
        errInfo = '401:访问令牌无效或已过期'
        break
      case 403:
        errInfo = '403:拒绝访问'
        break
      case 404:
        errInfo = '404:资源不存在'
        break
      case 405:
        errInfo = '405:请求方法未允许'
        break
      case 408:
        errInfo = '408:请求超时'
        break
      case 500:
        errInfo = '500:访问服务失败'
        break
      case 501:
        errInfo = '501:未实现'
        break
      case 502:
        errInfo = '502:无效网关'
        break
      case 503:
        errInfo = '503:服务不可用'
        break
      default:
        errInfo = '连接错误'
    }
    let message = res?.data?.message
    return {
      status,
      message: message || errInfo
    }
  }

}